home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / readin.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  3KB  |  96 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /* readin.c */
  21.  
  22. #include "externs.h"
  23.  
  24.  
  25. void AVL_READ_IN()
  26. {
  27.     AVL_EDIT_WINDOW_PTR w;
  28.     AVL_LINE_PTR temp, head = NULL;
  29.     AVL_WIN_PTR m1;
  30.     short n1, n2, x, i, n, rp;
  31.     AVL_SOURCE_SIZE t;
  32.     char s[121];
  33.     int first = 0;
  34.     static char fname[121];
  35.     static char lastfn[121];
  36.     static char *msg = "GWAda - Get from which file? ";
  37.     char msg2[80];
  38.     w = &avl_windows[avl_window];
  39.     n1 = 62;
  40.     n2 = (80 - n1) / 2;
  41.     m1 = AVL_MAKE_WINDOW(msg,7,n2,9,n1+n2,avl_wnd_bk_color,avl_wnd_color);
  42.     if (first == 0)
  43.         sprintf(lastfn,"%s%c*.ada",avl_dir_sources,92);
  44.     strcpy(fname,lastfn);
  45.     first = 1;
  46.     rp = AVL_PROMPT(1,1,fname,60);
  47.     if (fname[0] == '\0' || rp)   {
  48.             AVL_DEL_WINDOW(m1);
  49.             return;
  50.             }
  51.     strcpy(lastfn,fname);
  52.     temp = AVL_MAKE_LINE("### DUMMY ###",0);
  53.     AVL_LINE_INSERT(temp,&head);
  54.     AVL_GET_FILE_NAMES(&t,fname);
  55.     s[0] = '\0';
  56.     if (t.no_files == 0)  {
  57.         sprintf(s,"Can't find any file under \'%s\'",fname);
  58.         AVL_ERROR(s);
  59.         }
  60.     else  {        
  61.         n = AVL_SOURCES(&t,t.no_files,fname);
  62.         for(i = strlen(fname) - 1; t.no_files > 1 && i > 0; --i)  {
  63.             if (fname[i] == '\\' && i > 0) {
  64.                 fname[i+1] = '\0';
  65.                 i  = -10;
  66.                 break;
  67.                 }
  68.             }
  69.         if (i < -1)
  70.             sprintf(s,"%s%s",fname,t.name[n]);
  71.         else
  72.             sprintf(s, "%s",t.name[n]);
  73.         }
  74.     if (s[0] != '\0')  {
  75.         x = AVL_LOAD(s, &head);
  76.         if (!x) {
  77.             sprintf(msg2,"Can't open \'%s\'", s);
  78.             AVL_ERROR(msg2);
  79.             AVL_DEL_WINDOW(m1);
  80.             }
  81.         else {
  82.             AVL_DEL_WINDOW(m1);
  83.             AVL_CLEAR_BLOCK();
  84.             avl_block_first_line = head -> next;
  85.             avl_block_last_line = head -> previous;
  86.             avl_block_first_col = 0;
  87.             avl_block_last_col = strlen(head -> previous -> line) - 1;
  88.             if (avl_block_last_col < 0) avl_block_last_col = 0;
  89.             AVL_EDIT_COPY(1);
  90.             AVL_CLEAR_BLOCK();
  91.             }
  92.         }
  93.     else
  94.         AVL_DEL_WINDOW(m1);
  95. }
  96.